pub fn convert_base(num_str: &str, to_base: u32) -> String {
   // 1. 解析输入的字符串，提取数字和原始进制
   let (num, from_base_str) = num_str.split_at(num_str.find('(').unwrap());
   let from_base: u32 = from_base_str.trim_matches(|c: char| !c.is_digit(10))
                                     .parse()
                                     .expect("Failed to parse the base");

   // 2. 将 num 从 from_base 转换为十进制
   let mut num_decimal = 0u32;
   let num_chars = num.chars().collect::<Vec<char>>();
   for (i, c) in num_chars.iter().rev().enumerate() {
       let digit = c.to_digit(from_base).expect("Invalid digit for the given base");
       num_decimal += digit * from_base.pow(i as u32);
   }

   // 3. 将十进制数字转换为目标进制 (to_base)
   if num_decimal == 0 {
       return "0".to_string();
   }
   
   let mut result = String::new();
   let mut num = num_decimal;
   while num > 0 {
       let digit = (num % to_base) as u8;
       let digit_char = if digit < 10 {
           (digit + b'0') as char
       } else {
           (digit - 10 + b'a') as char  // 使用小写字母
       };
       result.push(digit_char);
       num /= to_base;
   } // test3


   // 4. 结果是反向的，所以需要将其反转
   result.chars().rev().collect()
}

